<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>未处理投诉</title>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
</head>
<body>
<!--<p>dddd</p>-->
<div id="viewUser">
    <template class="data">
        <el-input
                style="width:30%;margin-bottom: 10px;color: blue"
                placeholder="请输入搜索内容"
                v-model="query"
                clearable>
        </el-input>
        <el-button type="primary" size="small" @click="search()" style="height: 40px;width: 80px;margin-bottom: 10px">搜索</el-button>
        <el-table
                :data="tableData"
                border
                style="width: 100%">
            <el-table-column
                    prop="id"
                    label="反馈ID"
                    width="120">
            </el-table-column>
            <el-table-column
                    prop="complainId"
                    label="被反馈人ID"
                    width="120">
            </el-table-column>
            <el-table-column
                    prop="complainType"
                    label="被投诉对象类型"
                    width="120">
            </el-table-column>
            <el-table-column
                    prop="userid"
                    label="反馈人ID"
                    width="120">
            </el-table-column>
            <el-table-column
                    prop="time"
                    label="投诉时间"
                    width="120">
            </el-table-column>
            <el-table-column
                    prop="content"
                    label="反馈内容"
                    width="120">
            </el-table-column>
            <el-table-column
                    prop="status"
                    label="状态"
                    width="120">
            </el-table-column>
            <el-table-column label="操作" width="170" >
                <template slot-scope="scope">
                    <div id="update">
                        <el-popover
                                placement="right"
                                width="800"
                                height="600"
                                trigger="click">
                            <el-button  @click="getUpdateComplain(scope.row.id)" slot="reference">更新</el-button>
                            <el-descriptions v-model="form" title="投诉信息更新" :column="3"  border>
                                <template slot="extra">
                                    <el-button type="primary" size="small" @click="submit">提交</el-button>
                                    <el-button type="primary" size="small" @click="reset">重置</el-button>
                                </template>
                                <el-descriptions-item>
                                    <template slot="label">
                                        投诉ID
                                    </template>
                                    <el-input v-model="form.id" style="width: 200px;height: 30px"></el-input>
                                </el-descriptions-item>
                                <el-descriptions-item>
                                    <template slot="label">
                                        投诉人ID
                                    </template>
                                    <el-input v-model="form.userid" style="width: 200px;height: 30px" ></el-input>
                                </el-descriptions-item>
                                <el-descriptions-item>
                                    <template slot="label">
                                        被投诉ID
                                    </template>
                                    <el-input v-model="form.complainId" style="width: 200px;height: 30px"></el-input>
                                </el-descriptions-item>
                                <el-descriptions-item>
                                    <template slot="label">
                                        被投诉对象
                                    </template>
                                    <el-input v-model="form.complainType" style="width: 200px;height: 30px"></el-input>
                                </el-descriptions-item>
                                <el-descriptions-item>
                                    <template slot="label">
                                        时间
                                    </template>
                                    <el-input v-model="form.time" style="width: 200px;height: 30px"></el-input>
                                </el-descriptions-item>
                                <el-descriptions-item>
                                    <template slot="label">
                                        内容
                                    </template>
                                    <el-input v-model="form.content" style="width: 200px;height: 30px" ></el-input>
                                </el-descriptions-item>
                                <el-descriptions-item>
                                    <template slot="label">
                                        状态
                                    </template>
                                    <el-input v-model="form.status" style="width: 200px;height: 30px"></el-input>
                                </el-descriptions-item>
                            </el-descriptions>
                        </el-popover>
                    </div>
                    <el-button  @click="delete(scope.row.id)" >删除</el-button>
                </template>
            </el-table-column>
        </el-table>
        <!--分页-->
        <el-pagination
                :current-page="current"
                :page-size="limit"
                :total="total"
                style="padding:30px 0; margin-top:20px; text-align: center;"
                layout="prev, pager, next"
                @current-change="search"></el-pagination>
    </template>
</div>

<script src="../../js/vue.js"></script>
<script src="../../js/axios.min.js"></script>
<script src="../../js/element-ui/index.js"></script>

<script  >

    new Vue({
        el:'#viewUser',
        data : function (){
            return{
                tableData: [],  //表格中的所有数据
                current:0,      //当前页码
                limit:3,        //每页展示记录数
                total:0,        //总记录数
                query:'',      //查询条件
                form:{
                    id:'',
                    userid:'',
                    content:'',
                    complain:'',
                    status:'',
                    time:'',
                    complainType:''
                },
                complainStatus:1
            }
        },
        created(){
            this.search()
        },
        methods: {
            delete(id){
                axios.delete(`/deleteCompain/${id}`)
                    .then(response=>{
                        let code = response.data.code
                        let message = response.data.message
                        if(code===200){
                            this.$message({showClose: true,message: msg,type: 'success'});
                            this.search()
                        }else{
                            this.$message({showClose: true,message: message,type: 'error'});
                        }
                    })
            },
            getUpdateComplain(id){
                axios.get(`/getComplain/${id}`)
                    .then(response=>{
                        let code = response.data.code
                        let msg = response.data.msg
                        if(code===200){
                            this.form = response.data.data
                        }else{
                            this.$message({showClose: true,message: msg,type: 'error'});
                        }
                    })
            },
            submit(){
                console.log(this.form)
                axios.put('/updateComplain',this.form)
                    .then(response=>{
                        let code = response.data.code
                        let msg = response.data.msg
                        if(code===200){
                            this.$message({showClose: true,message: msg,type: 'success'});
                            this.search()
                        }else{
                            this.$message({showClose: true,message: msg,type: 'error'});
                        }
                    })
            },
            reset(){
                this.id = null
                this.userid= null
                this.content= null
                this.complain=null
                this.status= null
                this.time= null
                this.complainType=null
            },
            search(page=1){
                this.current = page
                console.log(this.current)
                axios.get('/searchComplain?current='+this.current+'&query='+this.query+'&complainStatus='+this.complainStatus)
                    .then(response=>{
                        console.log(response)
                        this.tableData = response.data.data.pageInfo.list
                        this.current = response.data.data.pageInfo.pageNum
                        this.total = response.data.data.pageInfo.total
                        this.query = response.data.data.query
                        this.complainStatus = response.data.data.complainStatus
                    })
                    .catch(error=>{
                        console.log(error)
                    })
            }
        }
    })
</script>
</body>
</html>